var CopyPlugin = require('copy-webpack-plugin');
 
const path = require('path');
 
module.exports = {
  entry: {
    workflow: './src/workflow.js',
    process: './src/process.js',
    processinstance: './src/processinstance.js',
    processdetail: './src/processdetail.js',
    rules: './src/rules.js',
    ruleslist: './src/ruleslist.js',
    ruledetail: './src/ruledetail.js',
  },
  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist'),
    clean: true,
  },
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /\.less$/i,
        use: ['style-loader', 'css-loader', 'less-loader'],
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        type: 'asset/resource',
      },
      {
        test: /\.(bpmn|dmn)$/i,
        use: ['raw-loader'],
      },
    ],
  },
  plugins: [
    new CopyPlugin({
      patterns: [
        { from: 'node_modules/bootstrap/dist/css/bootstrap.min.css', to: 'vendor/bootstrap/assets' },
        { from: 'node_modules/bootstrap/dist/js/bootstrap.bundle.min.js', to: 'vendor/bootstrap/assets' },
        { from: 'node_modules/feather-icons/dist/feather.min.js', to: 'vendor/feather-icons/assets' },
        { from: 'node_modules/chart.js/dist/Chart.min.js', to: 'vendor/chart.js/assets' },
        { from: 'node_modules/keycloak-js/dist/keycloak.js', to: 'vendor/keycloak-js/assets' },
        { from: 'node_modules/bpmn-js/dist/assets', to: 'vendor/bpmn-js/assets' },
        { from: 'node_modules/bpmn-js-properties-panel/dist/assets', to: 'vendor/bpmn-js-properties-panel/assets' },
        { from: 'node_modules/datatables.net/js/jquery.dataTables.min.js', to: 'vendor/datatables' },
        { from: 'node_modules/datatables.net-bs5/js/dataTables.bootstrap5.min.js', to: 'vendor/datatables' },
        { from: 'node_modules/datatables.net-bs5/css/dataTables.bootstrap5.min.css', to: 'vendor/datatables' },
        { from: 'node_modules/jquery/dist/jquery.min.js', to: 'vendor/jquery' },
        { from: 'node_modules/dmn-js/dist/assets', to: 'vendor/dmn-js/assets' },
        { from: 'node_modules/dmn-js-properties-panel/dist/assets', to: 'vendor/dmn-js-properties-panel/assets' },
        { from: 'src/workflow.html', to: 'workflow.html' },
        { from: 'src/process.html', to: 'process.html' },
        { from: 'src/processdetail.html', to: 'processdetail.html' },
        { from: 'src/processinstance.html', to: 'processinstance.html' },
        { from: 'src/rules.html', to: 'rules.html' },
        { from: 'src/ruleslist.html', to: 'ruleslist.html' },
        { from: 'src/ruledetail.html', to: 'ruledetail.html' },
        { from: 'src/diagram.dmn', to: 'diagram.dmn' },
        { from: 'src/keycloak.json', to: 'keycloak.json' },
      ]
    }),
  ]
};